package com.halden.TRPG.controller;

import com.halden.TRPG.aop.LogInCheck;
import com.halden.TRPG.common.CodeEnum;
import com.halden.TRPG.common.Result;
import com.halden.TRPG.service.InitRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/initRoom")
public class InitRoomController {

    @Autowired
    private InitRoomService initRoomService;

    @LogInCheck
    @GetMapping("/init/{rid}/{uid}/{start}/{length}")
    public Result initRoom(@PathVariable("rid") Long rid,
                           @PathVariable("uid") String uid,
                           @PathVariable("start") Long start,
                           @PathVariable("length") Long length){
        CodeEnum codeEnum = initRoomService.initRoom(rid, uid, start, length);
        return Result.ok(200).add("data",codeEnum.getData());
    }
}
